package com.czmh.etc.onlinepubsys.configuration;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonManager {
	
	@Value("${redisson.address}")
	private String addressUrl;
	@Value("${redisson.password}")
	private String password;
	@Value("${redisson.database}")
	private Integer database;
	
	@Bean
	public RedissonClient getRedisson() throws Exception{
		RedissonClient redisson = null;
		Config config = new Config();
		config.useSingleServer()
			  .setAddress(addressUrl).setPassword(password).setDatabase(database);
		redisson = Redisson.create(config);
		
		System.out.println(redisson.getConfig().toJSON().toString());
		return redisson;
	}
	
	
}
